package com.ddwl.gate.dao;

import com.ddwl.common.dao.TkDao;
import com.ddwl.schema.bo.gate.AutoRefundConfigBo;
import com.ddwl.gate.mapper.AutoRefundConfigMapper;
import com.ddwl.gate.model.AutoRefundConfig;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;

/**
 * @Author hemiaojun
 * @Date 2020/10/27 11:25
 */
@Repository
public class AutoRefundConfigDao extends TkDao<AutoRefundConfigMapper, AutoRefundConfig> {

    @Resource
    private AutoRefundConfigMapper autoRefundConfigMapper;

    public void openOrCloseAutoRefund(AutoRefundConfigBo bo) {
        AutoRefundConfig entity = new AutoRefundConfig();
        AutoRefundConfig query=this.selectOne(entity);
        if (null == query) {
            entity.setAutoRefund(bo.getAutoRefund());
            this.insert(entity);
        }else{
            entity.setId(query.getId());
            entity.setAutoRefund(bo.getAutoRefund());
            updateByPrimaryKeySelective(entity);
        }
    }

    public AutoRefundConfig get(){
        AutoRefundConfig entity = new AutoRefundConfig();
        return selectOne(entity);
    }

    public void changeId(String oldId, String newId) {
        autoRefundConfigMapper.changeId(oldId,newId);
    }
}
